package kr.hkit.androidcomplete01.chaptert11;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class EditSelectEx extends Activity {
	EditText mEdit;
	int start;
	int end ;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch11_editselect);
		
		mEdit = (EditText) findViewById(R.id.ch11_edit);
	}
	
	public void mOnClick(View v){
		switch(v.getId()){
		case R.id.ch11_home:
			mEdit.setSelection(0);
			break;
		case R.id.ch11_end:
			mEdit.setSelection(mEdit.getText().length());
			break;
		case R.id.ch11_selblock:
			end = mEdit.getSelectionEnd();
			mEdit.setSelection(3, end);
			break;
		case R.id.ch11_selall:
			mEdit.selectAll();
			break;
		case R.id.ch11_getset:
			start = mEdit.getSelectionStart();
			end = mEdit.getSelectionEnd();
			Toast.makeText(EditSelectEx.this, "start = " + start + ", end = " + end, Toast.LENGTH_SHORT).show();
			break;
		}
		
		
	}
}
